

//
//  SHChangeCardCell.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/10/17.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//

#import "BankCardModel.h"
#import "SHChangeCardCell.h"
@interface SHChangeCardCell()
@property(nonatomic,strong)  UIImageView *icon;
@property(nonatomic,strong)  UILabel *leftLabel;
@property(nonatomic,strong)  UILabel *nameLabel;
@property(nonatomic,strong)  UILabel *contentLabel;
@property (nonatomic,strong) UILabel *isAuthLabel;
@property(nonatomic,strong)  UIImageView *arrow;//右侧箭头

@end
@implementation SHChangeCardCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self configUI];
        
    }
    return self;
}

- (void)configUI{
    
    self.icon = [[UIImageView alloc]init];
    [self.contentView addSubview:self.icon];
    self.leftLabel = [[UILabel alloc]init];
    self.leftLabel.font = KSystemFont(__I6Width(14));
    self.leftLabel.text = @"当前收款卡";
    self.leftLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    [self.contentView addSubview:self.leftLabel];
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.font = KSystemFont(__I6Width(14));
    self.nameLabel.textColor = [UIColor colorWithHexString:@"#333333"];
    [self.contentView addSubview:self.nameLabel];
    self.contentLabel = [[UILabel alloc]init];
    self.contentLabel.font = KSystemFont(__I6Width(13));
    self.contentLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    [self.contentView addSubview:self.contentLabel];
    
//    UIView *line = [[UIView alloc]init];
//    line.backgroundColor = KLINECOLOR;
//    [self.contentView addSubview:line];
//    [line mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.left.mas_equalTo(self.contentView.mas_left).with.offset(__I6Width(0));
//        make.right.mas_equalTo(self.contentView.mas_right).with.offset(__I6Width(0));
//        make.height.mas_equalTo(__I6Height(0.5));
//        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(__I6Height(0));
//    }];
    
    
//    self.isAuthLabel = [[UILabel alloc]init];
//    self.isAuthLabel.textAlignment = NSTextAlignmentRight;
//    self.isAuthLabel.font = KSystemFont(__I6Width(13));
//    self.isAuthLabel.textColor = [UIColor colorWithHexString:@"ff801a"];
//    [self addSubview:self.isAuthLabel];
    self.arrow = [[UIImageView alloc]init];
    self.arrow.image = [UIImage imageNamed:@"jmarrow@2x.png"];
    [self.contentView addSubview:self.arrow ];
    
   
}
- (void)layoutSubviews{
//    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.mas_equalTo(__I6Width(40));
//        make.height.mas_equalTo(__I6Height(40));
//    make.left.mas_equalTo(self.mas_left).with.offset(__I6Width(10));
//        make.centerY.mas_equalTo(self.mas_centerY);
//    }];
    
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).with.offset(__I6Width(15));
        //make.centerY.mas_equalTo(self.mas_centerY);
        make.top.mas_equalTo(self.mas_top).with.offset(__I6Height(10));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.mas_right).with.offset(__I6Width(-40));
        //make.centerY.mas_equalTo(self.mas_centerY);
        make.top.mas_equalTo(self.mas_top).with.offset(__I6Height(10));
    }];
//    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//
//    make.right.mas_equalTo(self.isAuthLabel.mas_left).with.offset( __I6Width(-5));
//        make.centerY.mas_equalTo(self.isAuthLabel.mas_centerY);
////        make.top.mas_equalTo(self.mas_top).with.offset(__I6Height(10));
//    }];
//
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.mas_right).with.offset(__I6Width(-40));
        make.top.mas_equalTo(self.nameLabel.mas_bottom).with.offset(__I6Height(5));
    }];
    
    
    [self.arrow  mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.right.equalTo(self.contentView.mas_right).with.offset(__I6Width(-15));
        make.height.mas_equalTo(__I6Height(14));
        make.width.mas_equalTo(__I6Width(7.5));
    }];
    
    
}
- (void)setModel:(BankCardModel *)model{
    
    [self.icon sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:nil];
    if (model.bank_card_code.length > 4) {
        
        NSRange range = {model.bank_card_code.length - 4,4};
        NSString *laterSixStr = [model.bank_card_code substringWithRange:range];
        self.contentLabel.text = [NSString stringWithFormat:@"尾号%@",laterSixStr] ;
    }
    self.nameLabel.text= model.bank_name;
    
//    if (model.auth_4_status) {
//
//        self.isAuthLabel.text = @"(审核通过)";
//
//
//    }else{
//
//       self.isAuthLabel.text = @"(审核失败)";
//
//
//
//    }
    
    
//    if(model.using_choices == 2){
//        if (model.auth_4_status) {
//
//            self.isAuthLabel.text = @"(审核通过)";
//
//        }else{
//
//            self.isAuthLabel.text = @"(审核失败)";
//
//        }
//
//    }else{
//        if (model.is_auth == 1) {
//            self.isAuthLabel.text = @"";
//
//        }else if(model.is_auth == 5){
//            self.isAuthLabel.text = @"审核中";
//
//        }else{
//
//            if (model.auth_4_status) {
//
//                self.isAuthLabel.text = @"";
//
//            }else{
//
//                self.isAuthLabel.text = @"审核失败";
//
//            }
//
//        }
    
    
    
    
    
    
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    
    if (selected) {
        
        self.backgroundColor = KCELLHIGHTLIGHTED;
    }else{
        
        self.backgroundColor = [UIColor whiteColor];
        
        
        
        
        
    }
    
    
}
@end
